This repository was archived by the owner on Feb 14, 2026. It is now read-only.
Merged
Conversation
- Add dedicated HTTP server (startHookServer.ts) for receiving Claude session hooks - Generate temporary settings file with SessionStart hook configuration - Pass --settings flag to Claude CLI for hook integration - Update Session class with callback mechanism for session ID changes - Connect scanner to session callbacks for real-time session file tracking
bra1nDump
reviewed
Dec 22, 2025
src/claude/claudeLocal.ts
Outdated
| } | ||
|
|
||
| // Add hook settings for session tracking | ||
| if (opts.hookSettingsPath) { |
Contributor
There was a problem hiding this comment.
should we just pass this always? update opts to must include this - less branching == better
| logger.debug(`[START] Session hook received: ${sessionId}`, data); | ||
|
|
||
| // Update session ID in the Session instance | ||
| if (currentSession) { |
Contributor
There was a problem hiding this comment.
hmmm how is this going to work? What if we don't have a session?
Also dynamic import - lets not do that for the type above :D
|
|
||
| /** | ||
| * Consume one-time Claude flags from claudeArgs after Claude spawn | ||
| * Currently handles: --resume (with or without session ID) |
Contributor
There was a problem hiding this comment.
elaborate on what the responsibility of this code is
- hookSettingsPath now required (less branching) - Static import instead of dynamic for Session type - JSDoc for onSessionFound callback - Remove fake session ID generation - Add control flow docs in startHookServer.ts
ahundt
added a commit
to ahundt/happy-cli
that referenced
this pull request
Dec 30, 2025
Summary: Integrates PR slopus#99 (hook-based session tracking) and PR slopus#98 (Gemini/ACP integration) while preserving all offline mode and robustness features from the feature branch, plus DRY improvements. What changed: - Session hook server system for reliable Claude session ID capture - Gemini backend as alternative to Claude/Codex with ACP integration - Fixed memory leak in session.ts (stored interval reference + cleanup()) - Added socket connection check in apiSession.ts - Created shared offlineSessionStub.ts utility (DRY refactor) - Added gemini to profile compatibility validation - Preserved: offline mode, 5xx handling, profile system, tmux integration Files affected: - src/claude/runClaude.ts: Hook server + offline fallback integration - src/claude/session.ts: RAII cleanup, callback system, hookSettingsPath - src/claude/loop.ts: hookSettingsPath threading - src/claude/claudeLocal.ts: Hook parameters - src/claude/claudeRemote.ts: mapToClaudeMode() preserved - src/api/api.ts: Graceful 5xx handling preserved - src/api/apiSession.ts: Socket check restored - src/daemon/run.ts: Gemini added to agent selection - src/persistence.ts: Added gemini to ProfileCompatibilitySchema - src/utils/offlineSessionStub.ts: New shared DRY utility - src/codex/runCodex.ts: Updated to use shared offline stub - src/gemini/runGemini.ts: Added offline mode with shared stub - src/agent/*, src/gemini/*: New from main (no conflicts) - scripts/session_hook_forwarder.cjs: Hook forwarder from main Testable: npm test (266 pass, 8 fail - baseline unchanged)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Session Hook Tracking
Reliable Claude session ID tracking via native hooks.
How It Works
SessionStarthook pointing to the server--settings <path>flag and fires hook on session startFiles
src/claude/utils/startHookServer.tssrc/claude/utils/generateHookSettings.tsscripts/session_hook_forwarder.cjsWhy
Claude changes session ID on
--resume,--continue, and/compact. Previously Happy lost track of the active session. Now Claude notifies Happy directly via hooks.